
function dynamicPagingFunc(pages){


	var shou=pages.shou;/*首页*/
	var wei=pages.wei;/*尾页*/
	var shan=pages.shan;/*上一页*/
	var xia=pages.xia;/*下一页*/
	var sznum=pages.sznum;/*数字*/


	var pageTotal=pages.pageTotal || 1;
	var curPage=pages.curPage || 1;
	var doc = document;
	var paginationId=doc.getElementById(""+pages.paginationId+"") || doc.getElementById("page");
	var html = "";
	if(curPage>pageTotal){
		curPage = 1;
	}
		/*总页数小于5,全部显示*/
	if(pageTotal<=5){
		html = appendItem(pageTotal,curPage,html,shou,wei,shan,xia,sznum);
		paginationId.innerHTML = html;
	}
	/*总页数大于5时,分析当前页*/
	if(pageTotal>5){
		if(curPage<=4){
			html = appendItem(pageTotal,curPage,html,shou,wei,shan,xia,sznum);
			paginationId.innerHTML = html;
		}else if(curPage>4){
			html = appendItem(pageTotal,curPage,html,shou,wei,shan,xia,sznum);
			paginationId.innerHTML = html;
		}
	}
}
		
function appendItem(pageTotal,curPage,html,shou,wei,shan,xia,sznum){
	var starPage = 0;
	var endPage = 0;
	html+="<a href='"+shou+"'>首页</a>";
	html+="<a href='"+shan+"' id='prevBtn'>上一页</a>";
	if(pageTotal<=5){
		starPage = 1;
		endPage = pageTotal;
	}else if(pageTotal>5 && curPage<=4){
		starPage = 1;
		endPage = 4;
		if(curPage==4){
			endPage = 5;
		}
	}else{
		if(pageTotal==curPage){
			starPage = curPage-3;
			endPage = curPage;
		}else{
			starPage = curPage-2;
			endPage = curPage+1;
		}
		html+="<a href='"+sznum+"1'>1</a><span>...</span>";
	}
	
	for(var i=starPage;i<=endPage;i++){
		if(i==curPage){
			html+="<a id='first' href='"+sznum+i+"'>"+i+"</a>";
		}else{
			html+="<a href='"+sznum+i+"'>"+i+"</a>";
		}
	}

	if(pageTotal<=5){
		html+="<a href='#' id='nextBtn'>&gt;</a>";
	}else{
		if(curPage<pageTotal-2){
			html+="<span>...</span>";
		}
		if(curPage<=pageTotal-2){
			html+="<a href='"+sznum+pageTotal+"' >"+pageTotal+"</a>";
		}
		
	}
	html+="<a href='"+xia+"' id='nextBtn'>下一页</a>";
	html+="<a href='"+wei+"'>尾页</a>";
	return html;
}